package com.ecoolex.hotel.saas.ws;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.hotel.saas.core.manager.StoreAdManager;
import com.ecoolex.hotel.saas.core.manager.StoreAdPositionManager;
import com.ecoolex.hotel.saas.entity.StoreAd;
import com.ecoolex.hotel.saas.entity.StoreAdPosition;
import com.ecoolex.hotel.saas.pojo.QueryStoreAdDTO;

@Service
public class StoreAdServiceImpl implements StoreAdService{

	@Autowired
	private StoreAdManager adManager;

	@Autowired
	private StoreAdPositionManager positionManager;

	@Override
	public StoreAd addAd(StoreAd record, List<StoreAdPosition> positionList, String createUser) {
		return adManager.add(record, positionList, createUser);
	}

	@Override
	public StoreAd updateAd(StoreAd record, List<StoreAdPosition> positionList, String updateUser) {
		return adManager.update(record, positionList, updateUser);
	}
	
	@Override
	public void deleteAd(int adId, String updateUser) {
		adManager.delete(adId, updateUser);
	}

	@Override
	public void releaseAd(int adId, String updateUser) {
		adManager.release(adId, updateUser);
	}

	@Override
	public void offlineAd(int adId, String updateUser) {
		adManager.offline(adId, updateUser);
	}

	@Override
	public int checkAdExpiredAndUpdateStatus(String updateUser) {
		return adManager.checkExpiredAndUpdateStatus(updateUser);
	}

	@Override
	public Pagination<StoreAd> queryAd(QueryStoreAdDTO query, Sorting[] sorts, Page page) {
		return adManager.query(query, sorts, page);
	}

	@Override
	public List<StoreAd> queryEffectiveAd(Integer storeId, String position, String[] positionValue, int size) {
		return adManager.queryEffective(storeId, position, positionValue, size);
	}
	
	@Override
	public StoreAd getAdByAdId(int adId) {
		return adManager.getByAdId(adId);
	}

	@Override
	public List<StoreAdPosition> queryAdPositionByAdId(int adId) {
		return positionManager.queryByAdId(adId);
	}
}
